package gatperdut.chato.core.handler.craft;

import gatperdut.chato.core.ChatoServer;
import gatperdut.chato.core.craft.CraftController;
import gatperdut.chato.core.handler.ChatoHandler;
import gatperdut.chato.model.Chato.Craft.Craft;

import java.util.HashMap;
import java.util.Map;

public class CraftHandler extends ChatoHandler {

    // search according to command's string hash
    private final Map<Craft, CraftController> craftToController = new HashMap<Craft, CraftController>();

    public CraftHandler( ChatoServer chatoServer ) {
        super( chatoServer );
    }

    public Map<Craft, CraftController> getCraftToController() {
        return craftToController;
    }

    public CraftController findCraftController( String command ) {
        for ( Craft c : getCraftToController().keySet() ) {
            if ( c.getCommand().equals( command ) ) {
                return getCraftToController().get( c );
            }
        }

        return null;
    }

}
